package de.fhb.gds.cp.core;

import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;

/**
 * Klasse um den Hintergrund des Bildes zu bearbeiten.
 * @author Fil
 *
 */
public class CpFilterBackground {
	
	// Note: b = band
	public static void removeWeakValues(BufferedImage im, int threshold) {
		
		WritableRaster imr = im.getRaster();
		
		int width = imr.getWidth();
		int height = imr.getHeight();
		
		int iW = 0, iH = 0;
		
		while (iW != width) {
			while (iH != height) {
				if (imr.getSample(iW, iH, 0) < threshold) {
					imr.setSample(iW, iH, 0, 0);
				}
				
				iH++;
			}
			iW++;
			iH = 0;
		}
		
		im.setData(imr);
	}
	
}
